<?php

namespace mpend\controllers;

use mpend\models\AuthenticationForm;
use common\models\user\UserAuthent;
use Yii;
use mpend\models\AvatarForm;
use mpend\components\Controller;

/**
 * 用户认证
 * PassportController
 */
class AuthenticationController extends Controller {

    /**
     * Declares the allowed HTTP verbs.
     * Please refer to [[VerbFilter::actions]] on how to declare the allowed verbs.
     * @return array the allowed HTTP verbs.
     */
    protected function verbs() {
        return [
            '*' => ['POST']
        ];
    }

    /**
     * Declares the allowed HTTP verbs.
     * Please refer to [[VerbFilter::actions]] on how to declare the allowed verbs.
     * @return array the allowed HTTP verbs.
     */
    protected function rules() {
        return [
            [
                'actions' => ['create'],
                'allow' => true,
                'roles' => ['@'],
            ],
        ];
    }

    /**
     * 账号认证
     * @return mixed
     */
    public function actionCreate() {

        $model = new AuthenticationForm();
        if (!$model->load(Yii::$app->request->post(), '')) {
            parent::error('用户认证信息不能为空');
        }
        return $model->save();
    }

}
